<?php
/**
 * Created by PhpStorm.
 * User: mj
 * Date: 17-6-5
 * Time: 上午10:26
 */

namespace App\Winged\Middleware;


use Illuminate\Http\Request;

class EnableCrossRequest
{
    const ALLOW_ORIGIN = 'Access-Control-Allow-Origin';
    const ALLOW_HEADERS = 'Access-Control-Allow-Headers';
    const ALLOW_METHODS = 'Access-Control-Allow-Methods';
    const ALLOW_CREDENTIALS = 'Access-Control-Allow-Credentials';


    public function handle(Request $request, \Closure $next)
    {
        $response = $next($request);
        $response->header(self::ALLOW_ORIGIN , config('app.allow_origin'));
        $response->header(self::ALLOW_HEADERS , '*');
        $response->header(self::ALLOW_METHODS , '*');
        $response->header(self::ALLOW_CREDENTIALS , '*');
        return $response;
    }
}
